package cn.bgs.service.impl;

import cn.bgs.common.R;
import cn.bgs.pageUtil.MybatisPageHelper;
import cn.bgs.pageUtil.PageRequest;
import cn.bgs.pageUtil.PageResult;
import cn.bgs.pojo.MonthCard;
import cn.bgs.mapper.MonthCardMapper;
import cn.bgs.service.IMonthCardService;
import cn.bgs.vo.MonthVo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 月卡表 服务实现类
 * </p>
 *
 * @author cf
 * @since 2022-06-07
 */
@Service
public class MonthCardServiceImpl extends ServiceImpl<MonthCardMapper, MonthCard> implements IMonthCardService {
    @Autowired
    MonthCardMapper monthCardMapper;


    @Override
    public boolean updateYkinfo(MonthVo monthVo) {
        int i = monthCardMapper.updateYkinfo(monthVo);
        if (i>0){
            return true;
        }
        return false;
    }

    @Override
    public boolean addYkInfo(MonthVo monthVo) {
        boolean a = monthCardMapper.addYkInfo(monthVo);
        return a;
    }

    @Override
    public R delYkInfo(Integer cardId) {
        int delte = monthCardMapper.delYkInfo(cardId);
        return R.ok().data("data",delte);
    }

    @Override
    public R selectPcInfo(MonthVo monthVo) {
        MybatisPageHelper.startPage(monthVo.getPageRequest());
        PageResult pageResult = MybatisPageHelper.getPageResult(monthCardMapper.selectPcInfo(monthVo));
        return R.ok().data("data",pageResult);
    }

//    @Override
//    public List<MonthVo> selectPcInfo() {
//        return monthCardMapper.selectPcInfo();
//    }



    @Override
    public int buyMonthCard(MonthCard monthCard) {
        monthCardMapper.updateCarMonthState(monthCard.getVehicleCarId());
        return monthCardMapper.buyMonthCard(monthCard);
    }
}
